﻿set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Zain Shaikh
-- Create date: Dec 13, 2011
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[DeleteCommercial]
	@CreatedDate datetime
AS
BEGIN
	DELETE FROM [dbo].[Commercial]	WHERE [CreatedDate] = @CreatedDate;
	RETURN @@RowCount;
END

GO




SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Zain Shaikh
-- Create date: Dec 12, 2011
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE SearchCommercials
	-- Add the parameters for the stored procedure here
	@CurrentDate datetime = null
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT CreatedDate as [Date], Count(CreatedDate) as [Count]
	FROM Commercial
	GROUP by CreatedDate
	HAVING (CreatedDate = ISNULL(@CurrentDate,CreatedDate))
	ORDER BY CreatedDate DESC
END

GO


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Zain Shaikh
-- Create date: Dec 13, 2011
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[SaveCommercial]
	@TypeId int
	,@Script varchar(max)
	,@CreatedBy int
	,@CreatedDate datetime
AS
BEGIN
	INSERT INTO [dbo].[Commercial]	
		([TypeId]
		,[Script]
		,[CreatedBy]
		,[CreatedDate])
     VALUES
		(@TypeId
		,@Script
		,@CreatedBy
		,@CreatedDate)
END


SET ANSI_NULLS ON



